package com.drool.mediaplayer.Database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

import com.drool.mediaplayer.Database.MediaFilesDB.AudioFiles;
import com.drool.mediaplayer.Database.MediaFilesDB.FileHeader;
import com.drool.mediaplayer.Database.MediaFilesDB.Playlist;
import com.drool.mediaplayer.Database.MediaFilesDB.PlaylistItems;
import com.drool.mediaplayer.Database.MediaFilesDB.VideoFiles;

public class MediaFilesDBHelper extends SQLiteOpenHelper {
	private static final String TAG = "Drool:MediaFilesDBHelper";
	private static final String DATABASE_NAME = "Media.db";
	private static final int DATABASE_VERSION = 1;
	
	public MediaFilesDBHelper (Context context){
		super(context, DATABASE_NAME, null, DATABASE_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		
		db.execSQL("CREATE TABLE " +FileHeader.HDR_TABLE_NAME+" ("    
	            + FileHeader._ID + " INTEGER PRIMARY KEY AUTOINCREMENT ,"
	            + FileHeader.HDR_FILE_NAME + " Text, "
	            + FileHeader.HDR_PATH + " Text, "
	            + FileHeader.HDR_DISP_NAME + " Text,"
	            + FileHeader.HDR_DATE_ADDED + " Text,"
	            + FileHeader.HDR_FILE_ID + " Integer,"
	            + FileHeader.HDR_FILE_TYPE + " Text"
	            + ");");
		
		db.execSQL("CREATE TABLE " +AudioFiles.AUDIO_TABLE_NAME+" ("  
	            + AudioFiles._ID + " INTEGER PRIMARY KEY AUTOINCREMENT ,"
	            //+ AudioFiles.AUDIO_ALBUM + " Text,"
	            + AudioFiles.AUDIO_ALBUM_ID + " Integer,"
	            //+ AudioFiles.AUDIO_ART + " Blob,"
	            + AudioFiles.AUDIO_ARTIST + " Text,"
	            + AudioFiles.AUDIO_GENRE + " Text,"
	            + AudioFiles.AUDIO_DURATION + " Text,"
	            + AudioFiles.AUDIO_TRACK + " Text,"
	            + AudioFiles.AUDIO_YEAR + " Text,"
	            + AudioFiles.AUDIO_NUM_OF_TIMES + " Integer"
	            + ");");
		
		db.execSQL("CREATE TABLE " + VideoFiles.VIDEO_TABLE_NAME+" ("  
	            + VideoFiles._ID + " INTEGER PRIMARY KEY AUTOINCREMENT ,"
	            + VideoFiles.VIDEO_ALBUM + " Text,"
	            //+ VideoFiles.VIDEO_ART + " Blob,"
	            + VideoFiles.VIDEO_ARTIST + " Text,"
	            + VideoFiles.VIDEO_GENRE + " Text,"
	            + VideoFiles.VIDEO_DURATION + " Text,"
	            + VideoFiles.VIDEO_LANGUAGE + " Text,"
	            + VideoFiles.VIDEO_DESCRIPTION + " Text,"
	            + VideoFiles.VIDEO_NUM_OF_TIMES + " Integer"
	            + ");");		
		
		db.execSQL("CREATE TABLE " + Playlist.PLAYLIST_TABLE_NAME + " ("
				+ Playlist._ID + " INTEGER PRIMARY KEY AUTOINCREMENT ,"
				+ Playlist.PLAYLIST_NAME + " Text,"
				+ Playlist.PLAYLIST_CREATED_ON + " Text"
				+ ");");
		
		db.execSQL("CREATE TABLE " + PlaylistItems.PLAYLIST_ITEMS_TABLE_NAME + " ("
				+ PlaylistItems._ID + " INTEGER PRIMARY KEY AUTOINCREMENT ,"
				+ PlaylistItems.PLAYLIST_ITEMS_MEDIA_ID + " Text,"
				+ PlaylistItems.PLAYLIST_ITEMS_MEDIA_NAME + " Text,"
				+ PlaylistItems.PLAYLIST_ITEMS_MEDIA_TYPE + " Text,"
				+ PlaylistItems.PLAYLIST_ITEMS_PL_ID + " Integer"
				+ ");");
	}

	@Override
	public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
		// TODO Auto-generated method stub
		Log.i(TAG, "Upgrade");
	}

	@Override
	public void onOpen(SQLiteDatabase db) {
		// TODO Auto-generated method stub
		super.onOpen(db);
	}
}
